package com.flca.frw.util
{
	import mx.core.UIComponent;
	import mx.styles.CSSStyleDeclaration;
	
	public class StyleHelper
	{
        import mx.styles.StyleManager;
        
        private static var stylesList:Array = [
            'fontSize',  'fontWeight', 'fontFamily', 'fontStyle', 'color', 'backgroundColor',  'backgroundAlpha',
        ];

		public static function setStyles(aUicomp: UIComponent, aStylename: String) : void 
		{
	        var selectors:Array = StyleManager.selectors;
	        for (var i:int = 0; i < selectors.length; i++) {
	        	var csstyl: String = selectors[i].toString(); 
	        	if (csstyl == "." + aStylename) {
//	        		trace("reading stylename = " + aStylename);
		            for (var j:int = 0; j < stylesList.length; j++) {
		                var cssvalue:String = CSSStyleDeclaration(StyleManager.getStyleDeclaration(csstyl)).getStyle(stylesList[j]);
		                if (cssvalue != null) {
//		                	trace("set style " + stylesList[j] + " : " + cssvalue);
							aUicomp.setStyle(stylesList[j], cssvalue);
		                }
		            }
	        	}
	        }
		}
	}
}